import { View } from "../../../mvc/core/View";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { LayerManager } from "../../manager/LayerManager";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { DailyRule } from "../../rules/DailyRule";
import { TimeEvent } from "../../events/TimeEvent";
import { ClockManager } from "../../manager/ClockManager";
import { Cache } from "../../cache/Cache";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class LoginOpenServerIcon
    
    export  class LoginOpenServerIcon extends View
    {
        constructor()
        {
            super();
            if (LoginOpenServerIcon._instance) 
            {
                throw new Error("LoginOpenServerIcon 单例");
            }
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            buttonMode = true;
            this._openServerIconBtn = ObjCreate.createGLoadedButton(ResFileConst.OpenServerIcon, 0, 0, 60, 50, this);
            addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            layer = LayerManager.rightTopUILayer;
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.DailyGiftOpen, DailyRule.OpenServerAct));
            return;
        }

        /* internal  */onServerOpenDayChangeHandler(arg1: TimeEvent): void
        {
            if (ClockManager.instance.serverOpenDateNum > Cache.instance.daily.openServerIconShowDay) 
            {
                this.hide();
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            return;
        }

        public static hasInstance(): Boolean
        {
            return !(LoginOpenServerIcon._instance == null);
        }

        public static get instance(): LoginOpenServerIcon
        {
            if (!LoginOpenServerIcon._instance) 
            {
                LoginOpenServerIcon._instance = new LoginOpenServerIcon();
            }
            return LoginOpenServerIcon._instance;
        }

        /* internal */ /* var */_openServerIconBtn: GLoadedButton;

        /* internal */ static /* var */_instance: LoginOpenServerIcon;
    }
